﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace IRepository
{
    public interface IBaseRepository<T> where T : class
    {
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="entity">添加实体</param>
        /// <returns>返回添加实体成功或失败</returns>
        Task<bool> AddAsync(T entity);
        /// <summary>
        /// 修改实体
        /// </summary>
        /// <param name="entity">修改实体</param>
        /// <returns>返回修改实体成功或失败</returns>
        Task<bool> UpdateAsync(T entity);
        /// <summary>
        /// 删除实体
        /// </summary>
        /// <param name="entity">删除实体</param>
        /// <returns>返回删除实体成功或失败</returns>
        Task<bool> DeleteAsync(T entity);
        /// <summary>
        /// 根据Id查找数据的方法
        /// </summary>
        /// <param name="id">查</param>
        /// <returns>返回查找数据的方法</returns>
        Task<T> GetAll(int id);
        /// <summary>
        /// 根据Id查找数据的实体
        /// </summary>
        /// <param name="id">查</param>
        /// <returns>返回查找数据的实体</returns>
        Task<T> GetAll(Expression<Func<T, bool>> predicate);
        /// <summary>
        /// 查询所有数据的方法
        /// </summary>
        /// <returns>返回查找数据的方法</returns>
        IQueryable<T> GetAllAsync();
        /// <summary>
        /// 查询所有数据的实体
        /// </summary>
        /// <returns>返回查询所有数据的实体</returns>
        IQueryable<T> GetAllAsync(Expression<Func<T, bool>> predicate);




        Task<int> UpdateAss(List<T> entities);
        Task<int> UpdateAsyncs(T entity);
    }
}
